<?php
if (!function_exists('rata2')) {
    function rata2($id_lesson) {
        $CI = & get_instance();
        $CI->load->database();

        $sql1 = 'SELECT DISTINCT id_user
            FROM exercise
            INNER JOIN rc_users ON rc_users.id = exercise.id_user
            WHERE rc_users.username <> "admin" AND rc_users.username <> "member" AND rc_users.username <> "super"';

        

        $query1 = $CI->db->query($sql1);
        if ($query->num_rows() > 0) {
            $result1 = $query->result_array();
            $query->free_result();
        } else {
            $result1 = array();
        }

        foreach ($result1 as $value1) {
            $sql = 'SELECT nilai FROM exercise WHERE id_lessons = '. $id_lessons .' AND id_user = '. $id_user .' ORDER BY tanggal DESC LIMIT 1';
        }
    }
}